package com.afd.ozblip.animation;

import com.afd.ozblip.activity.CouponActivity;
import com.afd.ozblip.activity.IndexActivity;
import com.afd.ozblip.activity.R;

import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;
import android.widget.TextView;

public class CouponTabAnimationListener implements AnimationListener {

	private View currentView;
	private CouponActivity indexActivity;

	public CouponTabAnimationListener(CouponActivity mainActivity, View view) {
		super();
		this.indexActivity = mainActivity;
		this.currentView = view;
	}

	@Override
	public void onAnimationEnd(Animation animation) {
		switch (currentView.getId()) {
		case R.id.tv_main_menu_text_home:
			indexActivity.nowIndex = 0;
			break;
		case R.id.tv_main_menu_text_category:
			indexActivity.nowIndex = 1;
			break;
		case R.id.tv_main_menu_text_me:
			indexActivity.nowIndex = 2;
			break;

		default:
			break;
		}
		TextView[] tabText = indexActivity.getTabTextArr();
		tabText[indexActivity.oldIndex].setTextColor(0xff999999);
		tabText[indexActivity.nowIndex].setTextColor(-1);
		tabText[indexActivity.oldIndex].setEnabled(true);
		tabText[indexActivity.nowIndex].setEnabled(false);
		ImageView[] tabImage = indexActivity.getTabImageArr();
		tabImage[indexActivity.oldIndex].setVisibility(4);
		tabImage[indexActivity.nowIndex].setVisibility(0);
		if (indexActivity.nowIndex == -1) {

		} else {
			indexActivity.mTabHost.setCurrentTab(indexActivity.nowIndex);
		}
	}

	@Override
	public void onAnimationRepeat(Animation animation) {

	}

	@Override
	public void onAnimationStart(Animation animation) {

	}

}
